<head th:fragment="headerCss">
    <meta charset="utf-8">
    <title>全国职业院校技能大赛-教师赛</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta name="keywords" content=""/>
    <meta name="description"
          content="全国职业院校技能大赛-教师赛"/>
    <link rel="stylesheet" href="/js/layui/css/layui.css">
    <!-- Bootstrap CSS File -->

    <link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/examination/common.css">
    <link rel="shortcut icon" href="../../bitbug_favicon.ico">
    <style>
        .marR10 {
            width: 20px;
            height: 20px;
            display: block;
            float: left;
            margin: 2px 10px 0 0;
        }

        .mar10 {
            width: 750px;
            margin-top: 20px;
            margin-left: auto;
            font-size: 16px;
        }

        label {
            display: block
        }

        a {
            color: #666;
        }

        #layui-layer1 .layui-layer-btn {
            text-align: center;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn0 {
            background: #FF6A66;
            color: #fff;
            border: none;
            font-size: 14px;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn1 {
            background: white;
            border: 1px solid #FF6A66;
            font-size: 14px;
        }

        .div-1 {
            margin: 50px auto;
            width: 200px;
            margin-left: 300px;
        }

        .resourceUrlImg, .resourceUrlVideo {
            width: 750px;
            margin-bottom: 30px;
        }

        .resourceUrlImg img, .resourceUrlVideo video {
            width: 100%;
            height: 300px;
        }

        .titles {
            margin-left: 30px;
            font-size: 30px;
            font-weight: 800;
        }

        .titles::after {
            width: 10px;
            height: 50px;
            top: 20px;
            left: 10px;
            background-color: #4886f8;
        }

        #content {
            margin-left: 30px;
            float: left;
        }

        #content h6 {
            font-weight: bold;
        }

        .updtaon {
            margin-top: 20px;
        }

        .updtaon p {
            margin-top: 10px;
            font-size: 18px;
        }
        .infoBox {
            background:none !important;
        }
        .signin {
            background: url("../../img/loginbgs.png");
        }
        .info {
            width: 100% !important;
            padding: 0 50px;
            margin-top: 30px !important;
        }
        .heading {
            width: 100%;
            padding: 0 30px;
            margin: 19px auto 25px
        }
        .slogan  {
            width: 100%;
            padding-left: 50px;
            opacity: 1;
            font-size: 50px;
        }
        .options {
            width: 68%;
            padding: 20px 0;
            margin-left: 20px;
            border-radius: 10px;
            background-color: rgba(255, 255, 255, 0.8);
        }
        #examShowtime {
            width: 28.5%;
            height: 85px;
            padding: 0 0;
            font-size: 20px;
            color: #FFFFFF;
            font-weight: 600;
            border-radius: 55px;
            background-color: rgba(255, 255, 255, 0.3);
        }
        #examShowtime #lastEndTime {
            margin-left: 5px;
            line-height: 70px;
            font-size: 50px;
        }

        .around{
            box-sizing: border-box;
            margin: 0 20px;
            margin-left: 50px;
            margin-right: 80px;
            width: 95%;
            height: calc(100% - 260px);
            border-radius: 10px;
            padding: 30px 20px;
            padding-bottom: 0;
            background: #FFFFFF;
        }
        .topic {
            width: 100%;

        }

        .btn-block{
            margin-right: 0;
        }
        .attributes {
            display: flex;
        }
        .attributes h1{
            font-size: 30px !important;
        }
        .fastalertedImg {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 50%;
            left: 50%;
            translate: -50% -50%;
            background: rgb(0, 0, 0, 0.5);
        }
        .fastalertedImg img {
            width: 400px;
            position: absolute;
            top: 50%;
            left: 50%;
            translate: -50% -50%;
        }
        .MinutealertedImg {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 50%;
            left: 50%;
            translate: -50% -50%;
            background: rgb(0, 0, 0, 0.5);
        }
        .MinutealertedImg img {
            width: 400px;
            position: absolute;
            top: 50%;
            left: 50%;
            translate: -50% -50%;
        }
        .redlogo {
            width: 205px;
            margin-top: 0;
        }
    </style>
</head>
<body class="signin" style="overflow-x: hidden">

<div class="infoBox">
    <div class="info">
        <div class="redlogo"><img src="/img/loaintitles.png" style="width: 350px;"></div>
        <div class="attributes">
<!--            <h1 id="roomNumber"></h1>-->
<!--            <h1 id="seatNumber"></h1>-->

<!--            <div id="idCard"></div>-->
<!--            <div id="ticketNumber"></div>-->
            <h1 id="name" style="margin-left: 455px;margin-top: 5px"></h1>
<!--            <button style="font-size: 23px" class="btn btn-block" id="next" onclick="reload();"><img style="width: 30px;" src="/img/refresh.png"/>刷新</button>-->
        </div>
    </div>
</div>


<div class="heading">

    <div class="options">
        <p class="slogan"><img style="margin-right: 20px;margin-bottom: 5px;width: 30px;" src="/img/蒙版组 123@2x.png"></img>幼儿园保教活动课件制作</p>
    </div>
    <div class="" id="examShowtime">
        <img style="width: 85px;margin-top: -17px" src="/img/组 1162@2x.png">
        <span style="font-size: 35px">本次竞赛剩余 </span>
        <span id="lastEndTime"></span>
    </div>

</div>

<div class="around">

    <div class="topic">
        <!--            <div class="subjectType">婴幼儿早期教育发展分析部分</div>-->
        <div class="login_panel" style="margin: auto;width: 100%;font-size:20px;">
            <!--<div>-->
            <!--<div class="mar40">一、单选题（共60题）</div>-->
            <!--</div>-->
            <!--<form id="signupForm">-->
            <!--<input type="hidden" name="stuSignId" id="stuSignId" />-->
            <!--<input type="hidden" name="epaperId" id="epaperId" />-->
<!--            <h6 class="titles">幼儿课件制作</h6>-->
            <div id="content" style="margin-top:10px;">
                <div style="font-size: 25px;font-weight: bold">根据素材给定内容完成课件制作</div>
                <div class="updtaon">
                    <img style="width: 150px;height: 150px;" src="/img/组 1194.png">
                    <p style="font-weight: bold">素材包见桌面素材包文件夹</p>
                </div>

            </div>
            <div style="width: 100%;;height: 10px;border-bottom: 1px dashed #b7c4df;float: left;margin-left: 30px"></div>
            <div id="btnUpload" style="float:left;text-align: center;margin-top: 20px;margin-left: 30px;">
                <img style="background: #fdfdef;border: 1px solid #f5efd8;width: 150px;height: 150px" src="/img/updatass.png">
                <p style="font-size: 14px;margin-top: 10px;font-weight: bold;font-size: 18px">点击上传</p>
                <input type="text" style="opacity:0;width: 1px;" id="fileRoute"
                       name="fileRoute"/>
                <span style="font-size: 14px;width: 100px;height: 100px" id="test" name="test"></span>
                <div style="margin-top: 15px;display: none" class="layui-progress layui-progress-big progress-me" lay-showpercent="true" lay-filter="demo">
                    <div class="layui-progress-bar layui-bg-red" lay-percent="0%"></div>
                </div>
            </div>
            <div id="btnUploadimg" style="float:left;text-align: center;margin-left: 30px;display: none;margin-top: 20px">
                <img src="/img/sssppt.png" style="background: #fdfdef;border: 1px solid #f5efd8;width: 150px;height: 150px">
                <p class="btnUploadimgtext" style="font-size: 17px;width:150px;margin-top: 10px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"></p>
            </div>

            <div class="adjust">

            </div>
        </div>
    </div>
    <div style="text-align: center">
        <button type="button" onclick="question()" style="background-color: #31b7ff;border: 0;padding: 15px 90px;border-radius: 20px;color: #FFFFFF;font-size: 25px">交卷 </button>
    </div>
</div>


</div>

<div class="alerted">
    <p class="query">是否交卷！</p>
    <div class="button">
        <span onclick="continuest()">继续考试</span>
        <span onclick="submitDate()">确认提交</span>
    </div>
</div>
<div class="audit">
    <p class="query">您还有考题未提交，确定交卷？</p>
    <div class="button">
        <span onclick="auditHide()">继续考试</span>
        <span onclick="submitDate()">确认提交</span>
    </div>
</div>
<div class="fastalertedImg" style="display: none">
    <img src="../../img/Fiveminutes.png"/>
    <img onclick="imgClose()" src="../../img/close.png" style="width: 30px;height: 30px;margin-top: -200px;margin-left: 190px">
</div>
<div class="MinutealertedImg" style="display: none">
    <img src="../../img/minute.png"/>
    <img onclick="imgClosemi()" src="../../img/close.png" style="width: 30px;height: 30px;margin-top: -200px;margin-left: 190px">
</div>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v=2.1.4}"></script>
<script src="/js/layui/layui.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"
        th:src="@{/js/plugins/validate/jquery.validate.min.js}"></script>
<script src="/js/plugins/validate/messages_zh.min.js" th:src="@{/js/plugins/validate/messages_zh.min.js}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script type="text/javascript">
    document.oncontextmenu = new Function("event.returnValue=false");
    document.onselectstart = new Function("event.returnValue=false");

    window.addEventListener('beforeunload',function(event){
        let e = event || window.event;
        e.preventDefault();
        if( e ){
            e.returnValue = '';
            return false;
        }
    })
    //
    // //f5、f12、f11禁用
    document.onkeydown = function (e) {
        var ev = window.event || e;
        var code = ev.keyCode || ev.which;
        if (code == 116 || 123 || 122 || 115) {
            if (ev.preventDefault) {
                // ev.preventDefault();
            } else {
                ev.keyCode = 0;
                ev.returnValue = false;
            }
        }

        // if ((window.event.altKey) &&

        if ( ((window.event.keyCode == 37) || //屏蔽Alt+方向键←
                (window.event.keyCode == 39))) { //屏蔽Alt+方向键→
            event.returnValue = false;
        }
        // if ((event.keyCode == 8) || //屏蔽退格删除键
        if (
            (event.keyCode == 116) || //屏蔽F5刷新键
            (event.ctrlKey && event.keyCode == 82)) { //Ctrl+R
            event.keyCode = 0;
            event.returnValue = false;
        }
        if (event.keyCode == 27) {
            event.keyCode = 0;
            event.returnValue = false;
        }
        if (event.keyCode == 122) {
            event.keyCode = 0;
            event.returnValue = false;
        } //屏蔽F11
        if (event.ctrlKey && event.keyCode == 78) event.returnValue = false; //屏蔽Ctrl+n
        if (event.shiftKey && event.keyCode == 121) event.returnValue = false; //屏蔽shift+F10
        if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
            window.event.returnValue = false; //屏蔽shift加鼠标左键新开一网页
        if ((window.event.altKey) && (window.event.keyCode == 115)) { //屏蔽Alt+F4
            window.showModelessDialog("about:blank", "", "dialogWidth:1px;dialogheight:1px");
            return false;
        }
    };


    var exam = JSON.parse(window.localStorage.getItem("exam"));
    var info = JSON.parse(window.localStorage.getItem("info"));
    var dates = JSON.parse(window.localStorage.getItem("dates"));//
    var dates1 = dates * 60;
    var allowNum = info.allowNum; // 允许三次切屏，超过则提交
    let name = ''
    const progressContainer = document.getElementById('progress');
    layui.use(['upload','element'], function () {
        var upload = layui.upload;
        var element = layui.element;
        upload.render({
            elem: '#btnUpload',
            url: '/common/sysFile/upload',
            // timeout: 36000000,
            // size: 1024 * 100,
            accept: 'file',
            // exts: 'docx|doc|xlsx|pdf|ppt',
             choose: function(obj){
                $('.progress-me').show()
                 var files = obj.pushFile();
                 var data = files
                 var values = Object.values(data);
                 for (let i = 0; i < values.length; i++) {
                     name = values[i].name
                 }
                 var keys = Object.keys(obj.pushFile());
                 var lastKey = keys[keys.length - 1];
                 for (const valuesKey in obj.pushFile()) {
                     if (valuesKey !== lastKey) {
                         delete obj.pushFile()[valuesKey];
                     }
                 }
             },
             progress: function(n, elem, e){ // 上传进度回调
                 if(n == 99 || n == 100) {
                     element.progress('demo', `${99}%`)
                 }else {
                     element.progress('demo', `${n}%`)
                 }
             },
            done: function (r) {
                if(r.code == "500") {
                   layer.msg(r.msg);
                   return
                }
                if(r.code === '200') {
                    element.progress('demo', `${100}%`)
                }
                $("#btnUploadimg").show()
                $(".btnUploadimgtext").attr('title',r.data)
                $(".btnUploadimgtext").html(name);
                $('.progress-me').hide()
                element.progress('demo', `${0}%`)
            },
            error: function (r) {
                layer.msg(r.msg);
                $('.progress-me').hide()
                element.progress('demo', `${0}%`)
            }
        });

    });


    function imgClose () {
        $('.fastalertedImg').hide()
    }

    function imgClosemi () {
        $('.MinutealertedImg').hide()
    }
    function onloads() {
        $.ajax({
            type: "get",
            url: "/jzweb/itemBank/getFile",
            data: {
                cbatchId: info.cbatchId
            },
            success: function (r) {
                if(r.code !=='0') {
                    layer.msg(r.msg);
                    return
                }
                for (let i = 0; i < r.data.length; i++) {
                    var link = document.createElement('a');
                    // 设置下载的链接
                    link.href = r.data[i];
                    // 设置下载的文件名
                    var filename = r.data[i].substring(r.data[i].lastIndexOf('/') + 1).split('?')[0];
                    link.download = filename
                    // 模拟点击下载链接
                    link.click();
                }

            }
        });
    }

    function question() {
        console.log('123')
        if(!$('.btnUploadimgtext').attr('title')) {
            $(".audit").show()
        }else {
            $(".alerted").show();
        }
        // $.ajax({
        //     type: "POST",
        //     url: "/jzApi/examinations/uploadpptById ",
        //     data: {
        //         stuSignId: info.stuSignId,
        //         pptfile: $("#test").html()
        //     },
        //     success: function (r) {
        //         //console.log("map =" , r.data.endTime);
        //     }
        // });
    }

    // layui.use(['upload'], function () {
    //     var upload = layui.upload;
    //     upload.render({
    //         elem: '#btnUpload',
    //         url: '/jzApi/examinations/uploadpptById',
    //         timeout: 36000000,
    //         // size: 1024 * 100,
    //         accept: 'file',
    //         data:{
    //             stuSignId: info.stuSignId
    //         },
    //         // exts: 'docx|doc|xlsx|pdf|ppt',
    //         done: function (r) {
    //             $("#fileRoute").val(r.data);
    //             $("#test").html(subFileName(r.data));
    //         },
    //         error: function (r) {
    //             layer.msg(r.msg);
    //         }
    //     });
    // });
    // window.onblur = function() {
    //     var el = document.documentElement;
    //     // 这里的 el 可以是其他的页面元素，这样实现的就是这个元素的全屏，而不是整个页面的全屏
    //     fullScreen(el);
    //     if(allowNum < 1) {
    //         submit()
    //     }
    //     allowNum--;
    //     layer.confirm("你已切屏，注意切屏次数过多将会强制交卷！！！", {
    //         btn: ['确定', '取消']
    //     });
    // };
    // //
    // window.onclick = document.onclick = function (e) {
    //     var el = document.documentElement;
    //     //这里的 el 可以是其他的页面元素，这样实现的就是这个元素的全屏，而不是整个页面的全屏
    //     fullScreen(el);
    // };

    function fullScreen(el) {
        var rfs = el.requestFullScreen || el.webkitRequestFullScreen ||

            el.mozRequestFullScreen || el.msRequestFullScreen;

        if (typeof rfs != "undefined" && rfs) {

            rfs.call(el);

        } else if (typeof window.ActiveXObject != "undefined") {

            //for IE，这里其实就是模拟了按下键盘的F11，使浏览器全屏

            var wscript = new ActiveXObject("WScript.Shell");

            if (wscript != null) {

                wscript.SendKeys("{F11}");

            }

        }
    }

    //单选 多选 切换
    $(".tap").find('dd').click(function () {
        let idx;
        $(this).addClass('active').siblings().removeClass('active');
        changeCss(idx)
    })

    $('#sub').attr("title", "考试时间大于" + dates + "分钟才能交卷！");

    //题目总数
    var allsubject = '';
    var index = 0;
    $(function () {
        // $("#roomNumber").html("考场号：" + info.roomNumber);
        // $("#seatNumber").html("座位号：" + info.seatNumber);
        $("#name").html("二次加密序号：" + info.num2);
        $("#idCard").html("考生编号：" + info.idCard);
        $("#ticketNumber").html("准考证号：" + info.ticketNumber);
        //$("#photo").attr("src", info.photo);
        $("#stuSignId").val(info.stuSignId);
        $("#epaperId").val(exam.id);
        //倒计时
        $.ajax({
            type: "POST",
            url: "/jzApi/examinations/getNowDateTime",
            data: {},
            success: function (r) {
                //console.log("map =" , r.data.endTime);
                window.localStorage.setItem("nowDate", r);
                countDown();
            }
        });
        // $('.fastalertedImg').on('click',function () {
        //     // $('.fastalertedImg').hide()
        // })
        // $('.MinutealertedImg').on('click',function () {
        //     $('.MinutealertedImg').hide()
        // })
        $('#lastEndTime').on('DOMSubtreeModified', function(event) {  // 绑定DOMSubtreeModified事件
            if(event.target.innerHTML == '00:05:00') {
                // layer.msg('考试时间5已到,自动提交试卷');
                $('.fastalertedImg').show()
            }
            if(event.target.innerHTML == '00:01:00') {
                // layer.msg('考试时间1已到,自动提交试卷');
                $('.MinutealertedImg').show()
            }

        });
        function addZero(i) {
            return i < 10 ? "0" + i : i + "";
        }

        var set;

        function countDown() {

            var nowTime = new Date(window.localStorage.getItem("nowDate").replace(/-/g, "/"));
            window.localStorage.setItem("nowDate", new Date(nowTime.getTime() + 1000));
            var info = JSON.parse(window.localStorage.getItem("info"));
            //监督员设置了延时
            if (info.endDate != undefined) {
                var endTime = new Date(info.endDate.replace(/-/g, "/")); //考试结束时间
                //console.log("endTime11",endTime)
            } else {
                var endTime = new Date(JSON.parse(window.localStorage.getItem("intro")).endTimes.replace(/-/g, "/")); //考试结束时间
            }
            if (window.localStorage.getItem("endTimes") != undefined) {
                var endTime = new Date(window.localStorage.getItem("endTimes").replace(/-/g, "/"));
            }

            var leftTime = parseInt((endTime.getTime() - nowTime.getTime()) / 1000);
            var h = parseInt(leftTime / (60 * 60) % 24);
            var m = parseInt(leftTime / 60 % 60);
            var s = parseInt(leftTime % 60);
            // d = addZero(d)
            h = addZero(h);
            m = addZero(m);
            s = addZero(s);
            document.querySelector("#lastEndTime").innerHTML = h + ':' + m + ':' + s;

            if (info.name.indexOf("jzwy") != -1 || leftTime <= dates1) {
                $("#sub").attr("disabled", false);
                $("#sub").removeClass("not-allowed");
            }

            set = setTimeout(countDown, 1000);
            if (leftTime < 0) {
                layer.msg('考试时间已到,自动提交试卷');
                submitDate()
                clearInterval(set);
                return
            }

        }

        //上传
        //  function updtas() {
        //
        //  }


        // getData(0);
        //渲染答题卡选中状态
        // $('.mar10').click(function () {
        //     var that = $(this);
        //     var examId = that.parents('.titleEaxm').attr('data-id');
        //     var type = that.parents('.titleEaxm').attr('type');
        //     /*根据题目ID找到对应答题卡*/
        //     var cardLi = $('li[data-id=' + examId + ']');
        //     //多选题
        //     if (type == 1) {
        //         var a = true;//控制答题卡是否选中
        //         var b = false;//判断选项是否选中
        //         if (!that.find("input").prop('checked')) {
        //             that.siblings(".mar10").each(function () {
        //                 //选择了一个选项则为true
        //                 if ($(this).find("input").prop('checked')) {
        //                     b = true
        //                 }
        //             });
        //
        //         } else {
        //             b = true;
        //         }
        //         if (a) {
        //             if (b) {
        //                 cardLi.addClass('hasBeenAnswer');
        //             } else {
        //
        //                 cardLi.removeClass('hasBeenAnswer');
        //             }
        //         } else {
        //             cardLi.removeClass('hasBeenAnswer');
        //         }
        //     }
        //     else if( type != 4 ){
        //         if (!cardLi.hasClass('hasBeenAnswer')) {
        //
        //             cardLi.addClass('hasBeenAnswer');
        //         }
        //     }
        //
        //     $(this).find('textarea').change(function (e){
        //         if( e.target.value ){
        //             if ( type == 4 ) {
        //                 if (!cardLi.hasClass('hasBeenAnswer')) {
        //
        //                     cardLi.addClass('hasBeenAnswer');
        //                 }
        //             }
        //         }else{
        //             cardLi.removeClass('hasBeenAnswer');
        //         }
        //     })
        //
        // });
        //
        //点击答题卡跳转题目
        $('.anLi').click(function () {


            $('.anLi').attr('style', '').find('a').attr('style', '');
            $(this).css({'background': '#4886f8', 'border': '1px solid #4886f8'}).find('a').css('color', '#fff');

            // var examId = $(this).attr('data-id');
            // /*选中题目ID*/
            // var cardLi = $('div[data-id=' + examId + ']');
            // /*根据题目ID找到对应答题卡*/
            // cardLi.addClass('contentBoxShow');
            // cardLi.removeClass('contentBoxHide');
            // cardLi.siblings().addClass('contentBoxHide');
            // cardLi.siblings().removeClass('contentBoxShow');


            $(".subjectType").text('婴幼儿早期教育发展分析部分');


            index = $(this).attr('data-index');

            if (index >= exam.questions.length - 1) {
                $(".green").css('background', '#ccc').attr('disabled', true);
            } else {
                $(".green").css('background', '#43BD00').attr('disabled', false);
            }

            if (index <= 0) {
                $(".gray").css('background', '#ccc').attr('disabled', true);
            } else {
                $(".gray").css('background', '#43BD00').attr('disabled', false);
            }

            toGo(index)
        });

        //答案存入缓存
        $("textarea").change(function () {
            let textBox = []
            $('.titleEaxm').each(function (i, res) {
                var that = $(this);
                var che = '';
                var type = that.find("textarea").attr("type");
                //文本框
                if (type == 'text') {
                    if (that.find($('textarea')).val() != '' && that.find($('textarea')).val() != undefined) {
                        textBox.push({
                            id: that.attr("data-id"),
                            value: that.find($('textarea')).val(),
                            type: that.attr('type')
                        });
                    }
                }
            });
            window.localStorage.setItem("textBox", JSON.stringify(textBox));
        });

        //从缓存取出答案、遍历到页面
        var textBox = window.localStorage.getItem("textBox");
        if (null != textBox) {
            var subject = '';
            var textBoxJSON = JSON.parse(textBox);
            //遍历题目
            $('.titleEaxm').each(function () {
                var that = $(this);
                for (var i = 0; i < textBoxJSON.length; i++) {
                    //根据id找到对应题目
                    if (that.attr("data-id") == textBoxJSON[i].id) {
                        if (textBoxJSON[i].value != '') {
                            $('li[data-id=' + textBoxJSON[i].id + ']').addClass('hasBeenAnswer');
                        }
                        // //判断空值
                        if (textBoxJSON[i].value != '' && that.find($('textarea')).val() != undefined) {
                            //遍历多选题答案
                            var valueList = textBoxJSON[i].value;
                            $(this).find('textarea').val(valueList)
                            break;
                        }
                    }
                    //进度显示
                    if (that.find($('input:checked')).val() != undefined) {
                        subject = subject * 1 + 1
                    }
                }
                //题目完成进度
                var process = (subject / allsubject) * 100;
                //未完成题目数量
                window.localStorage.setItem("incomplete", allsubject - subject);
                $("#process").html("共" + allsubject + "道题目，已完成" + process.toFixed(2) + "%");
            })
        } else {
            window.localStorage.setItem("incomplete", allsubject);
        }

    });


    function submitDate() {
        $.ajax({
            type: "POST",
            url: "/jzApi/examinations/uploadpptById ",
            data: {
                stuSignId: info.stuSignId,
                pptfile: $(".btnUploadimgtext").attr('title') ? $(".btnUploadimgtext").attr('title') : ''
            },
            success: function (r) {
                //console.log("map =" , r.data.endTime);
                if(r.code == 0) {
                    var name = info.name
                    var ticketNumber = info.ticketNumber
                    var idNumber = info.idCard
                    localStorage.removeItem("info");
                    localStorage.removeItem("exam");
                    localStorage.removeItem("intro");
                    localStorage.removeItem("answerList");
                    localStorage.removeItem("endTime");
                    localStorage.removeItem("dates");
                    localStorage.removeItem("incomplete");
                    localStorage.removeItem("times");
                    localStorage.removeItem("endTimes");
                    localStorage.removeItem("textBox");
                    // localStorage.clear();
                    location.href = '/examination/endExam?name=' + name + '&ticketNumber=' + ticketNumber + '&idNumber=' + idNumber;
                }else if(r.code === '-1') {
                    layer.msg(r.msg);
                    location.href = '/examination/endExam?name=' + name + '&ticketNumber=' + ticketNumber + '&idNumber=' + idNumber;
                }
                else {
                    layer.msg(r.msg);
                }

            }
        })
    }

    function continuest() {
        $(".alerted").hide();
    }
    function auditHide() {
        $(".audit").hide();
    }
    function questions() {

        var intro = JSON.parse(localStorage.getItem("intro"));
        // 考试开始时间 加半个小时
        var startTime = new Date(intro.startTime).getTime() + (60*30*1000);
        //当前时间
        var thisTime = new Date(window.localStorage.getItem("nowDate").replace(/-/g,"/"));
        //考试结束时间
        var endTime = new Date(intro.endTime).getTime();

        let isTrue = JSON.parse(localStorage.getItem('isTrue'));
        let tBox = [];
        //     let isTrue = true;
        if( isTrue ){

            $('.titleEaxm').each(function (i, res) {
                tBox.push({id: $(res).attr('data-id'), value: $(res).find('.subject').val(), type: $(res).attr("type")});
            })

            tBox.forEach(function (val){
                if( !val.value ){
                    $(".alerted").show();
                    return false;
                }
            })

            submit();

        }else{
            if( thisTime > startTime ){
                // $(".alerted").show();
                submitDate()
            }else if( endTime - thisTime <= (60*30*1000) ){
                $(".alerted").show();
            }else{

                layer.confirm("考试还未满30分钟,不能交卷", {
                    btn: ['确定', '取消']
                })
            }
        }

    }

    //获取题目数据
    // function getData(titleNumber) {
    //     var a = '<div>';//题目
    //     var c = '';//切换按钮
    //     var an = [];//单选答题卡
    //     var am = [];//多选答题卡
    //     var as = [];//婴幼儿早期教育发展分析答题卡
    //     allsubject = exam.questions.length;
    //     $("#process").html("共" + allsubject + "道题目，已完成0%");
    //     var arr = exam.questions;
    //     var t;
    //
    //     // 打乱题目顺序
    //     // for(var i = 0;i < arr.length; i++){
    //         // var rand = parseInt(Math.random()*arr.length);
    //         // t = arr[rand];
    //         // arr[rand] =arr[i];
    //         // arr[i] = t;
    //     // }
    //
    //     arr.forEach(function (item, index, arr) {
    //         //渲染答题卡
    //         if (item.type == 1) {
    //             am.push(item)
    //             // am += '<li class="anLi"  data-index="' + index + '" data-id="' + item.id + '"><a href="#">' + (parseInt(index)+1) + '</a></li>';
    //         }else if (item.type == 4) {
    //             as.push(item)
    //         }
    //         else {
    //             an.push(item)
    //             // an += '<li class="anLi"  data-index="' + index + '" data-id="' + item.id + '"><a href="#">' + (parseInt(index)+1) + '</a></li>';
    //         }
    //     })
    //
    //     var convan = [];
    //     let bs = '', bstr = '', f ;
    //     as.forEach(function (item, index, arr) {
    //         //控制题目展示
    //         if (titleNumber == index) {
    //             f = 'contentBoxShow box'
    //         } else {
    //             f = 'contentBoxHide box'
    //         }
    //         //婴幼儿早期教育发展分析应用题
    //         // if (item.type == 4) { //案例应用题
    //         if (item.resourceType == 0) {
    //             //写入题目选项
    //             bs = '<div class="mar10"><textarea type="text" placeholder="请输入您的回答" class="subject" style="border:1px solid #ccc;width:100%;height:200px;line-height: 20px;font-size: 16px;padding: 10px;border-radius:5px" id="' + item.id + '_' + i + '" name="' + item.id + '" ></textarea>'
    //                 + '</div>'
    //         }
    //
    //         //图片
    //         if(item.resourceType == 1){
    //             bs = `<div class="mar10">
    //                         <div class="resourceUrlImg"><img src="${item.resourceUrl}" alt=""></div>
    //                         <textarea type="text" placeholder="请输入您的回答" class="subject" style="border:1px solid #ccc;width:100%;height:200px;line-height: 20px;font-size: 16px;padding: 10px;border-radius:5px" id="${ item.id}_${index}" name="${item.id}" ></textarea>
    //                     </div>`;
    //         }
    //
    //         //视频
    //         if(item.resourceType == 2){
    //             bs = `<div class="mar10">
    //                         <div class="resourceUrlVideo"><video src="${item.resourceUrl}" controls></video></div>
    //                         <textarea type="text" placeholder="请输入您的回答" class="subject" style="border:1px solid #ccc;width:100%;height:200px;line-height: 20px;font-size: 16px;padding: 10px;border-radius:5px" id="${ item.id}_${index}" name="${item.id}" ></textarea>
    //                     </div>`;
    //         }
    //
    //         bstr += `<div type="${item.type}" class="${f} titleEaxm" data-id="${item.id}" data-index="${(convan.length + index)}"><div><span class='serial'>${(parseInt((index)) + 1) }</span><span class='bold'>  ${item.introduce }</span>（${ item.score }分） </div>${ bs }</div>`;
    //             // else if (item.resourceType == 1) {
    //             //     //写入题目选项
    //             //     for (var i = 0; i < list.length; i++) {
    //             //         b += '<div class="mar10"><input type="text" class="subject" id="' + item.id + '_' + i + '" name="' + item.id + '"  value="" />'
    //             //             + '</div>'
    //             //     }
    //             //     a += '<div type="' + item.type + '" class="' + f + ' titleEaxm" data-id="' + item.id + '" data-index="' + index + '"><div>' + "<span class='serial'>" + (parseInt(index)+1) + "</span>" + "<span class='bold'>" +'（婴幼儿早期教育发展分析）（' + item.score + '分）&nbsp;' + item.introduce+ "</span>" + '<img style="width: 500px;height: auto;" src="'+item.resourceUrl+'">' +'</img>'+  '</div>' + b;
    //             //
    //             // }
    //         // }
    //
    //     })
    //
    //     // return false;
    //     a += bstr;
    //     $("#content").html(a);
    //
    //     var str = '';
    //
    //     as.map(function (item, index) {
    //         if( index == 0 ){
    //             str += '<li class="anLi" style="background: rgb(72, 134, 248); border: 1px solid rgb(72, 134, 248);" data-type=" ' + item.type + '"  data-index="' + (parseInt(an.length + am.length + index)) + '" data-id="' + item.id + '"><a href="#" style="color: #fff">' + (parseInt(an.length + am.length + index) + 1) + '</a></li>';
    //         }else {
    //             str += '<li class="anLi"  data-type=" ' + item.type + '"  data-index="' + (parseInt(an.length + am.length + index)) + '" data-id="' + item.id + '"><a href="#">' + (parseInt(an.length + am.length + index) + 1) + '</a></li>';
    //         }
    //     })
    //
    //     $("#case").html(str)  //答题卡
    //
    // }

    function toGo(index) {
        changeCss(index)
    }

    function first() {
        index = 0;
        $(".gray").css('background', '#ccc').attr('disabled', true);
        $(".green").css('background', '#43BD00').attr('disabled', false);

        $(".subjectType").text('婴幼儿早期教育发展分析部分');
        changeCss(index)
    }

    function last() {
        index = exam.questions.length - 1;
        $(".gray").css('background', '#43BD00').attr('disabled', false);
        $(".green").css('background', '#ccc').attr('disabled', true);
        $(".subjectType").text('婴幼儿早期教育发展分析部分');

        changeCss(index)
    }

    function next() {
        index = parseInt(index) + parseInt(1);
        if (index > 0) {
            $(".gray").css('background', '#43BD00').attr('disabled', false);
        }
        if (index >= exam.questions.length) {
            $(".green").css('background', '#ccc').attr('disabled', true);
            index = exam.questions.length - 1;
        } else {
            $(".green").css('background', '#43BD00');
        }

        changeCss(index)
    }

    function pre() {
        index = parseInt(index) - parseInt(1);
        if (index < exam.questions.length) {
            $(".green").css('background', '#43BD00').attr('disabled', false);
        }
        if (index <= 0) {
            $(".gray").css('background', '#ccc').attr('disabled', true);
            index = 0;
        } else {
            $(".gray").css('background', '#43BD00');
        }

        changeCss(index)
    }

    //刷新考试结束时间
    function reload() {
        $.ajax({
            url: "/jzweb/exceptionAddtime/delayed",
            data: {
                stuId: JSON.parse(window.localStorage.getItem("info")).stuSignId,
                eBatchId: JSON.parse(window.localStorage.getItem("intro")).id
            },
            success: function (r) {
                let info = JSON.parse(window.localStorage.getItem("info"));
                info.endDate = r.data.endTime;
                window.localStorage.setItem('isTrue', JSON.stringify(r.data.isTrue));
                window.localStorage.setItem("endTime", r.data.endTime);
                window.localStorage.setItem("info", JSON.stringify(info));
            }
        });
    }

    //控制题目展示
    function changeCss(index) {
        $('.box').each(function (i, res) {
            if (index == i) {
                $(this).addClass("contentBoxShow");
                $(this).removeClass("contentBoxHide");
            } else {
                $(this).addClass("contentBoxHide");
                $(this).removeClass("contentBoxShow")
            }
        });

        $(".anLi").attr('style', '').find('a').attr('style', '');
        $(".anLi").eq(index).css({
            'background': 'rgb(72, 134, 248)',
            'border': ' 1px solid rgb(72, 134, 248)'
        }).find('a').css('color', '#fff');

    }

    //提交答卷
    function submit() {

        // var t = Math.round(Math.random());
        //0-9随机数
        var t = Math.floor(Math.random() * 10);
        // var textBox = window.localStorage.getItem("textBox");
        // var tolBox = [];
        var textBox = [];
        var examBatchId;
        var id = layer.msg('提交中，请等待！', {
            icon: 16,
            shade: 0.4,
            time: false //取消自动关闭
        });

        $('.titleEaxm').each(function (i, res) {
            textBox.push({id: $(res).attr('data-id'), value: $(res).find('.subject').val(), type: $(res).attr("type")});
        })

        textBox = JSON.stringify(textBox);

        // if (!textBox) {
        //     textBox = [];
        //     $('.titleEaxm').each(function (i, res) {
        //         textBox.push({id: $(res).attr('data-id'), value: '', type: $(res).attr("type")});
        //     })
        // }

        // type ==1  现在的题目(应用分析题)
        // type ==2  理论题
        setTimeout(function () {
            $.ajax({
                type: "POST",
                url: "/jzApi/examinations/selAnswerSheet",
                data: {
                    stuSignId: info.stuSignId,
                    epaperId: exam.id,
                    answerList: textBox,
                    code: info.cookieCode,
                    // type: '4'
                },
                success: function (r) {
                    //console.log("r",r)
                    if (r.code == 0) {
                        //提交试卷后清除缓存
                        var name = info.name
                        var ticketNumber = info.ticketNumber
                        var idNumber = info.idCard
                        localStorage.removeItem("info");
                        localStorage.removeItem("exam");
                        localStorage.removeItem("intro");
                        localStorage.removeItem("answerList");
                        localStorage.removeItem("endTime");
                        localStorage.removeItem("dates");
                        localStorage.removeItem("incomplete");
                        localStorage.removeItem("times");
                        localStorage.removeItem("endTimes");
                        localStorage.removeItem("textBox");
                        // localStorage.clear();
                        location.href = '/examination/endExam?name=' + name + '&ticketNumber=' + ticketNumber + '&idNumber=' + idNumber;
                    } else {
                        layer.msg(r.msg);
                    }
                }
            });
        }, t * 1000);
    }
</script>
</body>





